package com.example.player.dao;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;

import com.example.player.domain.entity.Song;

import java.util.List;
import java.util.Set;

import io.reactivex.rxjava3.core.Completable;
import io.reactivex.rxjava3.core.Flowable;

/**
 * 本类为歌曲的dao层
 * @author 朱文权
 * */
@Dao
public interface SongDao {
    @Insert
    Completable insert(Song song);
    @Delete
    Completable delete(Song song);
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    Completable insertSongs(List<Song> songs);
    @Query("select * from songs")
    Flowable<List<Song>> getAllSongs();
    /**
     * 查询某一歌单的歌曲
     * */
    @Query("select * from songs inner join song_list_rela on songs.sid=song_list_rela.sid where song_list_rela.pid=:pid")
    Flowable<List<Song>> getPlayListSongs(Long pid);
    /**
     * 查询歌曲路径
     * */
    @Query("select path from songs")
    Flowable<List<Song>> getAllSongsPath();
    /**
     * 清除数据库
     * */
    @Query("delete from songs")
    Completable deleteAll();
}
